import request from '@/utils/request'

export const projectDatasourcePostRequire = (server, params) => {
    let thisParams = Object.assign({},params);

    return new Promise((resolve) => {
        request({
            url: 'api/projectDatasource/' + server,
            method: 'post',
            data: thisParams
        }).then((response) => {
            if ("listPage" === server && response.data && response.data.records) {
                let arr = response.data.records || []
                arr.forEach(a => {

                })
            }
            resolve(response)
        })
    })
}

export const projectDatasourceDownload = (server, params, responseType) => {
    let thisParams = Object.assign({},params);

  return request({
    url: 'api/projectDatasource/' + server,
    method: 'post',
    data: thisParams,
    responseType: responseType || "blob"
  })
}


export const projectDatasourcePostRequireByConfig = (server, params, config) => {
    let headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    return request({
        url: 'api/projectDatasource/' + server,
        method: 'post',
        data: params,
        headers: Object.assign(headers, config)
    })
}
